package com.cart.protocol.analyze;


import com.cart.protocol.ProtocolDefine;

/*
    ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ 
       Author   :  lixiaodaoaaa
       Date     :  2020-01-16
       Time     :  10:37
    ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
    关于 门指令回复的解析
 */
public class LiquidLevelRespAnalyze extends RespAnalyze {


    public LiquidLevelRespAnalyze(String rawDeviceInfo) {
        super(rawDeviceInfo);
    }

    @Override
    protected RespAnalyze analyze() {

        StringBuilder resultBuilder = new StringBuilder();

        switch (operatorCmd) {
            case ProtocolDefine.OperateCommand.READ:
                resultBuilder.append("读取");
                break;
            default:
                break;
        }
        resultBuilder.append("液位状态");

        switch (commandWordRes.toUpperCase()) {
            case ProtocolDefine.CommandWordRes.READ_SUCCESS:
                resultBuilder.append("成功");
                break;
            case ProtocolDefine.CommandWordRes.READ_FAIL:
                resultBuilder.append("失败");
                break;
            default:
                break;
        }

        resultBuilder.append(" ");
        resultBuilder.append("液位状态");
        String liquidLeveStatus = rawDeviceInfo.substring(rawDeviceInfo
                .length() - ProtocolDefine.ONE_BYTE_LEN);

        if (liquidLeveStatus.equals(ProtocolDefine.LiquidLevelStatus.NORMAL)) {
            resultBuilder.append("正常");
        } else {
            resultBuilder.append("异常");
        }
        report = resultBuilder.toString();
        return this;
    }
}
